class Solution {
    public void printStatistics(String str) {
        int len = str.length();
        int[] res = new int[4];
        for (int i = 0; i < len; i++) {
            char c = str.charAt(i);
            if (Character.isDigit(c)) {
                res[0]++;
            } else if (Character.isLetter(c)) {
                res[1]++;
            } else if (Character.isWhitespace(c)) {
                res[2]++;
            } else {
                res[3]++;
            }
        }
        System.out.printf("数字：%d个\n", res[0]);
        System.out.printf("字母：%d个\n", res[1]);
        System.out.printf("空格：%d个\n", res[2]);
        System.out.printf("其它：%d个\n", res[3]);
    }
}
